﻿namespace SpikingAnalyticsLib

open System
open System.Collections.Generic
open SpikingNeuronLib
open PatternExtensions

//=================================================================================================

// Extension methods on the Stimulus type
module StimulusExtensions =

    type SpikingNeuronLib.Stimulus with

    //---------------------------------------------------------------------------------------------------------
    // Static Extension methods

    /// Create an input pattern composed from a repeating linear pattern (ascending or descending)
    /// where repetitions are evenly spaced across each second (assumes N1000 network)
    static member CreateLinearInputPattern(patternStimulationsPerSecond:int, minTime, timeStep, maxTime) =
        let events = Pattern.CreateLinearSequence(minTime, timeStep, maxTime)
        new Stimulus(patternStimulationsPerSecond, events)

    // Create a Stimulus by combining two patterns
    static member Combine(firstPattern:Pattern, secondPattern:Pattern, patternStimulationsPerSecond:int) =
        let events =
            [ firstPattern.EventList; secondPattern.EventList; ]
            |> Seq.concat
        new Stimulus(patternStimulationsPerSecond, events)

    // Create a new Stimulus by combining the underlying patterns in each provided stimulus
    static member Combine(firstStimulus:Stimulus, secondStimulus:Stimulus, patternStimulationsPerSecond:int) =
        let events =
            [ firstStimulus.Pattern.EventList; secondStimulus.Pattern.EventList; ]
            |> Seq.concat
        new Stimulus(patternStimulationsPerSecond, events)
